Skip to contentSkip to conversation

Change in openvpn[master]: Prefer OpenSSL's SIPHASH implementation when available

Openvpn-devel plaisthos (Code Review) 1 participant 7 messages Sep 21, 2024 – Mar 19 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1677175662000.I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/31?usp=email

to review the following change.

Change subject: Prefer OpenSSL's SIPHASH implementation when available
......................................................................

Prefer OpenSSL's SIPHASH implementation when available

OpenSSL library is significantly faster than the reference implementation (almost 2x). Prefer using this when available. The API for using the SIPHASH MAC is different enough from using normal HMAC or Digest that we already implement that combining them into one API does not make sense.

SIPHASH is only available on OpenSSL 3.1 and later. We still check for support on 3.0 and later as the whole API to allow using the SIPHASH alrady exists in OpenSSL 3.0. Some of the later OpenSSL 3.0.x might get support for it. Theoretically, a provider can be loaded in OpenSSL 3.0 that implements SIPHASH.

Change-Id I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0

---
M CMakeLists.txt
M src/openvpn/Makefile.am
M src/openvpn/bloom.c
M src/openvpn/bloom.h
M src/openvpn/reflect_filter.c
M src/openvpn/siphash.h
A src/openvpn/siphash_openssl.c
M src/openvpn/siphash_reference.c
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/test_reflect.c

10 files changed, 253 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/31/31/9

CMakeLists.txt +2 -0
index 5aba2d4..0faf8da 100644
@@ -513,6 +513,7 @@
     src/openvpn/sig.c
     src/openvpn/sig.h
     src/openvpn/siphash.h
+    src/openvpn/siphash_openssl.c
     src/openvpn/siphash_reference.c
     src/openvpn/socket.c
     src/openvpn/socket.h
@@ -780,6 +781,7 @@
         src/openvpn/reflect_filter.h
         src/openvpn/siphash.h
         src/openvpn/siphash_reference.c
+        src/openvpn/siphash_openssl.c
         src/openvpn/otime.c
         src/openvpn/crypto_mbedtls.c
         src/openvpn/crypto_openssl.c
src/openvpn/Makefile.am +1 -0
index ca77718..f357764 100644
@@ -126,6 +126,7 @@
 	shaper.c shaper.h \
 	sig.c sig.h \
 	siphash_reference.c siphash.h \
+	siphash_openssl.c \
 	socket.c socket.h \
 	socks.c socks.h \
 	ssl.c ssl.h  ssl_backend.h \
src/openvpn/bloom.c +11 -1
index 729429e..6225e03 100644
@@ -170,10 +170,19 @@
 
     ALLOC_ARRAY_GC(bf->siphash_keys, struct siphash_key, bf->num_siphash, gc);
 
+    bf->siphash_ctx = siphash_cryptolib_init();
+
     bloom_clear(bf);
     return bf;
 }
 
+void
+bloom_free(struct bloom_filter *bf)
+{
+    siphash_cryptolib_uninit(bf->siphash_ctx);
+}
+
+
 /**
  * Clear the bloom filter, making it empty again as if it were freshly created
  * @param bf the bloom structure to clear
@@ -209,7 +218,8 @@
             if (idx == 0)
             {
                 /* We have no longer unused bytes in result, generate the next hash */
-                siphash(item, len, bf->siphash_keys[j++].key, result, SIPHASH_HASH_SIZE);
+                siphash(bf->siphash_ctx, item, len, bf->siphash_keys[j++].key,
+                        result, SIPHASH_HASH_SIZE);
             }
 
             bucket = bucket << 8;
src/openvpn/bloom.h +6 -0
index e180261..b35d784 100644
@@ -75,6 +75,9 @@
     /** keys for the siphash functions */
     struct siphash_key *siphash_keys;
 
+    /** (opaque) context for the siphash implementation */
+    void *siphash_ctx;
+
     /** the actual buckets that hold the data */
     bloom_counter_t buckets[];
 };
@@ -83,6 +86,9 @@
 struct bloom_filter *
 bloom_create(size_t size, size_t num_hashes, struct gc_arena *gc);
 
+void
+bloom_free(struct bloom_filter *bf);
+
 bloom_counter_t
 bloom_test(struct bloom_filter *bf, const uint8_t *item, size_t len);
 
src/openvpn/reflect_filter.c +1 -0
index 75445c0..f665e4c 100644
@@ -448,6 +448,7 @@
 void
 initial_rate_limit_free(struct initial_packet_rate_limit *irl)
 {
+    bloom_free(irl->bf);
     gc_free(&irl->gc);
     free(irl);
     irl = NULL;
src/openvpn/siphash.h +44 -4

56 lines not on this page · raw message

src/openvpn/siphash_openssl.c new file +149 -0

149 lines not on this page · raw message

src/openvpn/siphash_reference.c +2 -2
index 35af707..2a83b5e 100644
@@ -98,8 +98,8 @@
  *  outlen: length of the output in bytes, must be 8 or 16
  */
 int
-siphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
-        const size_t outlen)
+siphash_reference(const void *in, const size_t inlen, const void *k,
+                  uint8_t *out, const size_t outlen)
 {
 
     const unsigned char *ni = (const unsigned char *)in;
tests/unit_tests/openvpn/Makefile.am +1 -0
index cd1c378..9370360 100644
@@ -158,6 +158,7 @@
 	$(top_srcdir)/src/openvpn/packet_id.c \
 	$(top_srcdir)/src/openvpn/platform.c \
 	$(top_srcdir)/src/openvpn/siphash_reference.c \
+	$(top_srcdir)/src/openvpn/siphash_openssl.c \
 	$(top_srcdir)/src/openvpn/win32-util.c
 
 if !WIN32
tests/unit_tests/openvpn/test_reflect.c +36 -0
index 5158631..9238fe8 100644
@@ -41,7 +41,42 @@
 
 #include <stdio.h>
 
+static void
+test_siphash(void **state)
+{
+    const char *message = "Look behind you, a Three-Headed Monkey!";
 
+    uint8_t out[SIPHASH_HASH_SIZE];
+    const uint8_t key[SIPHASH_KEY_SIZE] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
+
+    siphash_reference(message, strlen(message), key, out, SIPHASH_HASH_SIZE);
+
+    const uint8_t expected_out[SIPHASH_HASH_SIZE] =
+    { 0x3e, 0xea, 0x95, 0xb2, 0x6d, 0x5c, 0x4e, 0xfa,
+      0x20, 0x47, 0x65, 0x7e, 0xdd, 0xcd, 0x62, 0x51};
+    assert_memory_equal(out, expected_out, SIPHASH_HASH_SIZE);
+
+    struct gc_arena gc = gc_new();
+    void *sipctx =  siphash_cryptolib_init();
+
+
+    uint8_t out2[SIPHASH_HASH_SIZE];
+
+    if (siphash_cryptolib_available(sipctx))
+    {
+        siphash_cryptolib(sipctx, message, strlen(message), key, out2,
+                          SIPHASH_HASH_SIZE);
+        assert_memory_equal(out, out2, SIPHASH_HASH_SIZE);
+
+        /* check that calling the function twice is safe */
+        siphash_cryptolib(sipctx, message, strlen(message), key, out2,
+                          SIPHASH_HASH_SIZE);
+        assert_memory_equal(out, out2, SIPHASH_HASH_SIZE);
+    }
+
+    siphash_cryptolib_uninit(sipctx);
+    gc_free(&gc);
+}
 
 static void
 test_bloom(void **state)
@@ -311,6 +346,7 @@
 {
     openvpn_unit_test_setup();
     const struct CMUnitTest tests[] = {
+        cmocka_unit_test(test_siphash),
         cmocka_unit_test(test_bloom_access_functions),
         cmocka_unit_test(test_bloom),
         cmocka_unit_test(test_bloom_minimal),

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 9
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw

[Openvpn-devel] [L] Change in openvpn[master]: Allow to use OpenSSL's SIPHASH implementation when available

In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/31?usp=email

to look at the new patch set (#10).

Change subject: Allow to use OpenSSL's SIPHASH implementation when available
......................................................................

Allow to use OpenSSL's SIPHASH implementation when available

OpenSSL library is currently slower than the reference implementation (about 1.5x to 2x depending of the compiler).

The OpenSSL API for using the SIPHASH MAC is different enough from using normal HMAC or Digest that we already implement that combining them into one API does not make sense.

SIPHASH is only available on OpenSSL 3.1 and later. We still check for support on 3.0 and later as the whole API to allow using the SIPHASH alrady exists in OpenSSL 3.0. Some of the later OpenSSL 3.0.x might get support for it. Theoretically, a provider can be loaded in OpenSSL 3.0 that implements SIPHASH.

With OpenSSL's implementation being slower, we currently only use it to check that our reference implementation and the OpenSSL implementation yield the same result in unit tests

Change-Id I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0

---
M CMakeLists.txt
M src/openvpn/Makefile.am
M src/openvpn/siphash.h
A src/openvpn/siphash_openssl.c
M src/openvpn/siphash_reference.c
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/test_crypto.c

7 files changed, 272 insertions(+), 12 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/31/31/10

CMakeLists.txt +7 -0
index 198c98f..8eb05f6 100644
@@ -556,6 +556,9 @@
     src/openvpn/shaper.h
     src/openvpn/sig.c
     src/openvpn/sig.h
+    src/openvpn/siphash.h
+    src/openvpn/siphash_openssl.c
+    src/openvpn/siphash_reference.c
     src/openvpn/socket.c
     src/openvpn/socket.h
     src/openvpn/socket_util.c
@@ -774,8 +777,12 @@
         src/openvpn/packet_id.c
         src/openvpn/mtu.c
         src/openvpn/mss.c
+        src/openvpn/siphash_reference.c
+        src/openvpn/siphash_openssl.c
         )
 
+    target_compile_definitions(test_crypto PRIVATE PREFER_OPENSSL_SIPHASH)
+
     target_sources(test_ssl PRIVATE
             tests/unit_tests/openvpn/mock_management.c
             tests/unit_tests/openvpn/mock_ssl_dependencies.c
src/openvpn/Makefile.am +2 -0
index ff8cc54..08c8250 100644
@@ -128,6 +128,8 @@
 	session_id.c session_id.h \
 	shaper.c shaper.h \
 	sig.c sig.h \
+	siphash_reference.c siphash.h \
+	siphash_openssl.c \
 	socket.c socket.h \
 	socket_util.c socket_util.h \
 	socks.c socks.h \
src/openvpn/siphash.h +48 -5

61 lines not on this page · raw message

src/openvpn/siphash_openssl.c new file +151 -0

151 lines not on this page · raw message

src/openvpn/siphash_reference.c +2 -2
index b21a86e..a06599f 100644
@@ -100,8 +100,8 @@
  *  outlen: length of the output in bytes, must be 8 or 16
  */
 int
-siphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
-        const size_t outlen)
+siphash_reference(const void *in, const size_t inlen, const void *k,
+                  uint8_t *out, const size_t outlen)
 {
     const unsigned char *ni = (const unsigned char *)in;
     const unsigned char *kk = (const unsigned char *)k;
tests/unit_tests/openvpn/Makefile.am +4 -1
index 1128eb4..4ed113a 100644
@@ -84,7 +84,9 @@
 	$(top_srcdir)/src/openvpn/platform.c \
 	$(top_srcdir)/src/openvpn/mtu.c \
 	$(top_srcdir)/src/openvpn/win32-util.c \
-	$(top_srcdir)/src/openvpn/mss.c
+	$(top_srcdir)/src/openvpn/mss.c \
+	$(top_srcdir)/src/openvpn/siphash_openssl.c \
+	$(top_srcdir)/src/openvpn/siphash_reference.c
 
 dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
 dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
@@ -97,6 +99,7 @@
 
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
+	-DPREFER_OPENSSL_SIPHASH \
 	@TEST_CFLAGS@
 ssl_testdriver_LDFLAGS = @TEST_LDFLAGS@  $(OPTIONAL_CRYPTO_LIBS)
 ssl_testdriver_SOURCES = test_ssl.c \
tests/unit_tests/openvpn/test_crypto.c +58 -4

86 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 10
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>

#3 lore raw

[Openvpn-devel] [L] Change in openvpn[master]: Allow to use OpenSSL's SIPHASH implementation when available

In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/31?usp=email )

Change subject: Allow to use OpenSSL's SIPHASH implementation when available
......................................................................

Patch Set 11: Code-Review-1

(2 comments)

File src/openvpn/siphash_openssl.c:

http://gerrit.openvpn.net/c/openvpn/+/31/comment/35b7160b_cf0664ea?usp=email :
PS11, Line 20: * You should have received a copy of the GNU General Public License along This is an old version of the GPL header, please update to the one currently used in the rest of the files.

http://gerrit.openvpn.net/c/openvpn/+/31/comment/e0286fcc_9737f6c0?usp=email :
PS11, Line 123: #else /* if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L */ The comment here is wrong

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 11
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Mar 2026 11:42:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#4 lore raw

[Openvpn-devel] [L] Change in openvpn[master]: Allow to use OpenSSL's SIPHASH implementation when available

In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/31?usp=email )

Change subject: Allow to use OpenSSL's SIPHASH implementation when available
......................................................................

Patch Set 12:

(1 comment)

File src/openvpn/siphash_openssl.c:

http://gerrit.openvpn.net/c/openvpn/+/31/comment/2d5438c5_a914d406?usp=email :
PS11, Line 20: * You should have received a copy of the GNU General Public License along

Quoted 1 line

This is an old version of the GPL header, please update to the one currently used in the rest of the […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 12
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 13:01:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>

#5 lore raw

[Openvpn-devel] [L] Change in openvpn[master]: Allow to use OpenSSL's SIPHASH implementation when available

In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/31?usp=email )

Change subject: Allow to use OpenSSL's SIPHASH implementation when available
......................................................................

Patch Set 12:

(1 comment)

File src/openvpn/siphash_openssl.c:

http://gerrit.openvpn.net/c/openvpn/+/31/comment/12f675bd_1df71d40?usp=email :
PS11, Line 123: #else /* if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L */

Quoted 1 line

The comment here is wrong

I will remove the comment since clang format does not seem to enforce this it is better to leave it out then to have to update it every time.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 12
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 13:03:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>

#6 lore raw

[Openvpn-devel] [L] Change in openvpn[master]: Allow to use OpenSSL's SIPHASH implementation when available

In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/31?usp=email )

Change subject: Allow to use OpenSSL's SIPHASH implementation when available
......................................................................

Patch Set 12:

(1 comment)

File src/openvpn/siphash_openssl.c:

http://gerrit.openvpn.net/c/openvpn/+/31/comment/c361959b_5b6e82b6?usp=email :
PS11, Line 123: #else /* if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L */

Quoted 1 line

I will remove the comment since clang format does not seem to enforce this it is better to leave it […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 12
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 13:05:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>

#7 lore raw

[Openvpn-devel] [L] Change in openvpn[master]: Allow to use OpenSSL's SIPHASH implementation when available

In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/31?usp=email

to look at the new patch set (#13).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: Allow to use OpenSSL's SIPHASH implementation when available
......................................................................

Allow to use OpenSSL's SIPHASH implementation when available

OpenSSL library is currently slower than the reference implementation (about 1.5x to 2x depending of the compiler).

The OpenSSL API for using the SIPHASH MAC is different enough from using normal HMAC or Digest that we already implement that combining them into one API does not make sense.

SIPHASH is only available on OpenSSL 3.1 and later. We still check for support on 3.0 and later as the whole API to allow using the SIPHASH alrady exists in OpenSSL 3.0. Some of the later OpenSSL 3.0.x might get support for it. Theoretically, a provider can be loaded in OpenSSL 3.0 that implements SIPHASH.

With OpenSSL's implementation being slower, we currently only use it to check that our reference implementation and the OpenSSL implementation yield the same result in unit tests

Change-Id I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0

---
M CMakeLists.txt
M src/openvpn/Makefile.am
M src/openvpn/siphash.h
A src/openvpn/siphash_openssl.c
M src/openvpn/siphash_reference.c
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/test_crypto.c

7 files changed, 270 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/31/31/13

CMakeLists.txt +7 -0
index 198c98f..8eb05f6 100644
@@ -556,6 +556,9 @@
     src/openvpn/shaper.h
     src/openvpn/sig.c
     src/openvpn/sig.h
+    src/openvpn/siphash.h
+    src/openvpn/siphash_openssl.c
+    src/openvpn/siphash_reference.c
     src/openvpn/socket.c
     src/openvpn/socket.h
     src/openvpn/socket_util.c
@@ -774,8 +777,12 @@
         src/openvpn/packet_id.c
         src/openvpn/mtu.c
         src/openvpn/mss.c
+        src/openvpn/siphash_reference.c
+        src/openvpn/siphash_openssl.c
         )
 
+    target_compile_definitions(test_crypto PRIVATE PREFER_OPENSSL_SIPHASH)
+
     target_sources(test_ssl PRIVATE
             tests/unit_tests/openvpn/mock_management.c
             tests/unit_tests/openvpn/mock_ssl_dependencies.c
src/openvpn/Makefile.am +2 -0
index ff8cc54..08c8250 100644
@@ -128,6 +128,8 @@
 	session_id.c session_id.h \
 	shaper.c shaper.h \
 	sig.c sig.h \
+	siphash_reference.c siphash.h \
+	siphash_openssl.c \
 	socket.c socket.h \
 	socket_util.c socket_util.h \
 	socks.c socks.h \
src/openvpn/siphash.h +47 -4

60 lines not on this page · raw message

src/openvpn/siphash_openssl.c new file +150 -0

150 lines not on this page · raw message

src/openvpn/siphash_reference.c +2 -2
index b21a86e..a06599f 100644
@@ -100,8 +100,8 @@
  *  outlen: length of the output in bytes, must be 8 or 16
  */
 int
-siphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
-        const size_t outlen)
+siphash_reference(const void *in, const size_t inlen, const void *k,
+                  uint8_t *out, const size_t outlen)
 {
     const unsigned char *ni = (const unsigned char *)in;
     const unsigned char *kk = (const unsigned char *)k;
tests/unit_tests/openvpn/Makefile.am +4 -1
index 1128eb4..4ed113a 100644
@@ -84,7 +84,9 @@
 	$(top_srcdir)/src/openvpn/platform.c \
 	$(top_srcdir)/src/openvpn/mtu.c \
 	$(top_srcdir)/src/openvpn/win32-util.c \
-	$(top_srcdir)/src/openvpn/mss.c
+	$(top_srcdir)/src/openvpn/mss.c \
+	$(top_srcdir)/src/openvpn/siphash_openssl.c \
+	$(top_srcdir)/src/openvpn/siphash_reference.c
 
 dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
 dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
@@ -97,6 +99,7 @@
 
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
+	-DPREFER_OPENSSL_SIPHASH \
 	@TEST_CFLAGS@
 ssl_testdriver_LDFLAGS = @TEST_LDFLAGS@  $(OPTIONAL_CRYPTO_LIBS)
 ssl_testdriver_SOURCES = test_ssl.c \
tests/unit_tests/openvpn/test_crypto.c +58 -4

86 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/31?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09aa27caa1a3aab0d1be6118b26d54a1c1bf7aa0
Gerrit-Change-Number: 31
Gerrit-PatchSet: 13
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>